package com.xd.alibabanacosconfigclient;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@EnableDiscoveryClient
@RefreshScope //主要用来让这个类下的配置内容支持动态刷新
@SpringBootApplication
public class AlibabaNacosConfigClientApplication {

    public static void main(String[] args) {
        SpringApplication.run(AlibabaNacosConfigClientApplication.class, args);
    }

    // nacos配置的参数
    @Value("${gongzhonghao:}")
    private String gongzhonghao;

    @GetMapping("/test")
    public String getGongzhonghao() {
        return gongzhonghao;
    }
}
